/*
 * Ethan Levine
 * 
 * The contents of this file are subject to the GNU General Public
 * License (GPL) v2.  The full contents of this license can be
 * found at Mathma's website, http://www.codeplex.com/mathma/license
 */

package mathma.core.form;

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

import mathma.core.expr.Expression;
import mathma.core.expr.VariableMapping;

import mathma.core.value.Value;
import mathma.core.value.ValueType;

/**
 * @since 0.1.5
 * @author Ethan Levine
 */
public abstract class MultiExpression<E extends Value, O extends Value>
        extends FormulaicExpression<E, O> {

    private final List<Expression<O>> operands;
    
    protected MultiExpression(ValueType<E> type, Expression<O>... operands) {
        super(type);
        if (operands.length == 0) {
            throw new IllegalArgumentException(
                    "MultiExpression instantiated with no operands.");
        }
        List<Expression<O>> tempOperands = new ArrayList<Expression<O>>();
        for (Expression<O> operand : operands) {
            tempOperands.add(operand);
        }
        this.operands = Collections.unmodifiableList(tempOperands);
    }
    
    protected MultiExpression(ValueType<E> type, List<Expression<O>> operands) {
        super(type);
        if (operands.size() == 0) {
            throw new IllegalArgumentException(
                    "MultiExpression instantiated with no operands.");
        }
        this.operands = Collections.unmodifiableList(operands);
    }
    
    @Override
    public List<Expression<O>> getOperands() {
        return operands;
    }
}